home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Utilities / Converters / Convert_MacPaint / Source / shared.subproj / RCS / testMac2NeXT.m,v < prev    next >
Text File  |  1995-06-12  |  3KB  |  128 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  beta10:1.1;
  5. locks    death:1.2;
  6. comment  @@;
  7.  
  8.  
  9. 1.2
  10. date     93.04.04.23.45.37;  author death;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     93.01.10.15.09.01;  author death;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @@
  22.  
  23.  
  24. 1.2
  25. log
  26. @Sun Apr  4 23:45:36 PDT 1993
  27. @
  28. text
  29. @#import "MacToNeXTText.h"
  30. #import "common.h"
  31. #import <stdio.h>
  32.  
  33. void main()
  34. {
  35.     Instance    converter;
  36.     Integer    index;
  37.     Character    theChar, strictChar;
  38.     CString        source = "Hi there how are you doing?";
  39.     ErrorCode        errorone, errortwo;
  40.     FILE*    theFile;
  41.     CString    result, buffer;
  42.     Integer    resultsize;
  43.     Integer    ctr, colctr = 1;
  44.  
  45.     converter = [[MacToNeXTText alloc] init];
  46.     //
  47.     //    Convert an ascii char, an existing 8 bit char, and a characcter we know won't convert
  48.     //
  49.     printf("Character A: %c (bool result: %d)\n",
  50.         [converter ConvertCharacter: 'A'],
  51.         [converter GetBooleanFrom: SECOND_RESULT]);
  52.  
  53.     printf("Character paragraph: %c (bool result: %d)\n",
  54.         [converter ConvertCharacter: 0xA6],
  55.         [converter GetBooleanFrom: SECOND_RESULT]);
  56.  
  57.     printf("Can't convert apple : %c  (bool result: %d)\n",
  58.         [converter ConvertCharacter: 0xF0],
  59.         [converter GetBooleanFrom: SECOND_RESULT]);
  60.     for (index = 0; index < 256; index++)
  61.     {
  62.         theChar = [converter ConvertCharacter: index];
  63.         [converter UseIM1: YES];
  64.         errorone = [converter GetErrorCode];
  65.         strictChar = [converter ConvertCharacter: index];
  66.         [converter UseIM1: NO];
  67.         errortwo = [converter GetErrorCode];
  68.         printf("Converting Mac 0x%X to NeXT 0x%X (%c)  (error: %d) [strict: 0x%X (%c) (error: %d)]\n",
  69.             index,
  70.             theChar, theChar, errorone,
  71.             strictChar, strictChar, errortwo);
  72.     }
  73.  
  74.     // part two.
  75.     buffer = NewCString(512);
  76.     
  77.     for (ctr = 0; ctr < 256; ctr++)
  78.     {
  79.         if (colctr != 16)
  80.         {
  81.             buffer[ctr*2] = ctr;
  82.             buffer[(ctr*2)+1] = ' ';
  83.             colctr++;
  84.         }
  85.         else
  86.         {
  87.             buffer[ctr*2] = ctr;
  88.             buffer[(ctr*2)+1] = '\r';
  89.             colctr = 1;
  90.         }
  91.     }
  92.     buffer[512] = EndOfCString;
  93.     printf("Source text is: \n%s\n", &buffer[1]); // skip initial null
  94.     result =(CString)  [converter ConvertString: (Pointer) buffer WithLength: 512];
  95.     resultsize = [converter GetIntegerFrom: SECOND_RESULT];
  96.     printf("Size of result: %d\n", resultsize);
  97.     printf("Results text is: \n");
  98.     for (ctr = 0; ctr < resultsize; ctr ++)
  99.         printf("%c", result[ctr]);
  100.     printf("\n");
  101.     //    test that it expands its internal buffer alright by giving it some text which we
  102.     //    know will multiply in size when it comes out. .. convert lots of apples
  103.     for (ctr = 0; ctr < 16; ctr++)
  104.         buffer[ctr] = 0xF0;
  105.     buffer[16] = EndOfCString;
  106.     printf("Source text is: \n%s\n", (CString)buffer);
  107.     result =(CString)  [converter ConvertString: (Pointer) buffer WithLength: 16];
  108.     resultsize = [converter GetIntegerFrom: SECOND_RESULT];
  109.     printf("Size of result: %d\n", resultsize);
  110.     printf("Results text is: \n");
  111.     for (ctr = 0; ctr < resultsize; ctr ++)
  112.         printf("%c", result[ctr]);
  113.     printf("\n");
  114.     
  115.     FreePointer(result);
  116.     FreePointer(buffer);
  117.     close(theFile);
  118.     [converter    free];
  119. }@
  120.  
  121.  
  122. 1.1
  123. log
  124. @Sun Jan 10 15:09:01 PST 1993
  125. @
  126. text
  127. @@
  128.